/**
 * 
 */
package com.honghao.student.dao.impl;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;

import com.honghao.student.dao.AbstractMongoDAO;
import com.honghao.student.dao.StudentDao;
import com.honghao.student.pojo.Student;
import com.mongodb.BasicDBObject;


/**
 * @author honghao.li
 *
 */
@Component
@Qualifier("StudentDaoMongoImpl")
public class StudentDaoMongoImpl extends AbstractMongoDAO implements StudentDao {
    
    private static final Logger LOGGER = LoggerFactory
            .getLogger(StudentDaoMongoImpl.class);
    
    /* (non-Javadoc)
     * @see com.honghao.student.dao.BaseDao#selectAll()
     */
    @Override
    public List<Student> selectAll() {
        return this.mongoTemplate.findAll(Student.class,"test"); 
    }

    /* (non-Javadoc)
     * @see com.honghao.student.dao.BaseDao#selectByKey(java.io.Serializable)
     */
    @Override
    public Student selectByKey(Integer id) {
        // TODO Auto-generated method stub
        return null;
    }

    /* (non-Javadoc)
     * @see com.honghao.student.dao.BaseDao#save(java.lang.Object)
     */
    @Override
    public int save(Student entity) {
        BasicDBObject doc = new BasicDBObject();
        doc.put("stuId", entity.getStuId());
        doc.put("stuName", entity.getStuName());
        try {
            this.mongoTemplate.insert(doc,"test");
        } catch (Exception e) {
            LOGGER.error("insert monggDB error",e);
        }
        return 0;
    }

    /* (non-Javadoc)
     * @see com.honghao.student.dao.BaseDao#update(java.lang.Object)
     */
    @Override
    public int update(Student entity) {
        // TODO Auto-generated method stub
        return 0;
    }

    /* (non-Javadoc)
     * @see com.honghao.student.dao.BaseDao#delete(java.io.Serializable)
     */
    @Override
    public int delete(Integer id) {
        // TODO Auto-generated method stub
        return 0;
    }

}
